<?php 
class MyorderController extends CommonController{


	public function __construct(){
		//调用父级构造函数
		parent::__construct();
		if(!isset($_SESSION['uid']) || !isset($_SESSION['username'])){
			//跳转
			$this->error("请先登入","Storelist/index");





		}
	}


	// 我的订单
	public function index(){
		$uid = Q('session.uid');
		$myorder = K('Oreder')->get_data(array('uid'=>$uid));
		$NewOrder=array();
		foreach ($myorder as $key => $value) {
			$NewOrder[] =  array(
				'myorder' =>$value,
				'shop' =>K('ShopOreder')->get_data(array('oid'=>$value['oid'])),
				'store' =>K('Store')->get_one_data(array('stid'=>$value['stid'])),
				);
			}

			

	


		
		
		
		$this->assign('NewOrder',$NewOrder);
		$this->display();
	}

	// 送餐地址
	public function address(){
		
		if(IS_POST){

			if(!K('Address')->create()) $this->error(k('Address')->error);
			$sex = Q('post.gender');
			if($sex==1){
				$sex = '男';
			}else if($sex==2) {
				$sex = '女';
			}
			$data = array(
				'name' => Q('post.name'),
				'cellphone' => Q('post.cellphone'),
				'sex'=>$sex,
				'detail' => Q('post.detail'),
				'uid'=>Q('session.uid',0,'intval')

				);

			K('Address')->add_data($data);
				
			
			$this->success("添加成功","index");
			

		}
		

		
		$this->display();	
	}
	// 收藏夹
	public function favorite(){
		$this->display();
	}
	// 代金卷
	public function Voucher(){
		$this->display();
	}
	// 账户设置
	public function account(){
		$this->display();
	}
}




 ?>